Beginners' guide

From ArchWiki
Revision as of 10:41, 17 August 2016 by Kynikos (Talk | contribs) (Undo revision 446844 by Delta Duhr (talk) thanks, but that's explained in General recommendations, in turn linked from #Post-installation)

Jump to: navigation, search

This document will guide you through the process of installing Arch Linux using the Arch Install Scripts. Before installing, you are advised to skim over the FAQ.

The community-maintained ArchWiki is the primary resource that should be consulted if issues arise. The IRC channel (irc://irc.freenode.net/#archlinux) and the forums are also excellent resources if an answer cannot be found elsewhere. In accordance with the Arch Way, you are encouraged to type man command to read the man page of any command you are unfamiliar with.

Tip: This guide is accessible from the live installation with the ELinks browser, after the #Connect to the Internet step. This can be done in a new virtual console, switching (Alt+arrow) between the console containing the web page, and the console where you are performing the installation. Similarly, the #archlinux IRC can be accessed using irssi.

Preparation

Arch Linux should run on any i686 compatible machine with a minimum of 256 MB RAM. A basic installation with all packages from the base group should take less than 800 MB of disk space.

See Category:Getting and installing Arch for instructions on downloading the installation medium, and methods for booting it to the target machine(s). This guide assumes you use the latest available version.

After booting into the installation media, you will be automatically logged in as the root user and presented with a Zsh shell prompt. For modifying or creating configuration files, typically in /etc, nano or vim are suggested.

UEFI mode

In case you have a UEFI motherboard with UEFI mode enabled, the CD/USB will automatically launch Arch Linux via systemd-boot.

To verify you are booted in UEFI mode, check that the following directory is populated:

# ls /sys/firmware/efi/efivars

See UEFI#UEFI Variables for details.

Set the keyboard layout

The default console keymap is set to us. Available choices can be listed with ls /usr/share/kbd/keymaps/**/*.map.gz.

Note: localectl list-keymaps does not work due to bug FS#46725.

For example, to change the layout to de-latin1, run:

# loadkeys de-latin1

If certain characters appear as white squares or other symbols, change the console font. For example:

# setfont lat9w-16

Connect to the Internet

The dhcpcd daemon is enabled on boot for wired devices, and will attempt to start a connection. To access captive portal login forms, use the ELinks browser.

Verify a connection was established, for example with ping archlinux.org. If no connection is available, see Network configuration or follow the below netctl examples. Otherwise, continue to #Update the system clock.

Netctl preparation

To prevent conflicts, stop the enabled dhcpcd service first, replacing enp0s25 with the correct wired interface:

# systemctl stop dhcpcd@enp0s25.service

Interfaces can be listed using ip link, or iw dev for wireless devices. They are prefixed with en (ethernet), wl (WLAN), or ww (WWAN).

Wireless

List available networks, and make a connection for a specified interface:

# wifi-menu -o wlp2s0

The resulting configuration file is stored in /etc/netctl. For networks which require both a username and password, see WPA2 Enterprise#netctl.

Other

Several example profiles, such as for configuring a static IP address, are available. Copy the required one to /etc/netctl, for example ethernet-static:

# cp /etc/netctl/examples/ethernet-static /etc/netctl

Adjust the copy as needed, and enable it:

# netctl start ethernet-static

Update the system clock

Use systemd-timesyncd to ensure that your system clock is accurate. To start it:

# timedatectl set-ntp true

To check the service status, use timedatectl status.

Prepare the storage devices

Warning: In general, partitioning or formatting will make existing data inaccessible and subject to being overwritten, i.e. destroyed, by subsequent operations. For this reason, all data that needs to be preserved must be backed up before proceeding.

In this step, the storage devices that will be used by the new system will be prepared. Read Partitioning for a more general overview.

Users intending to create stacked block devices for LVM, disk encryption or RAID, should keep those instructions in mind when preparing the partitions. If intending to install to a USB flash key, see Installing Arch Linux on a USB key.

Identify the devices

Identify the devices where the new system will be installed:

# lsblk

Not all devices listed are viable mediums for installation; results ending in rom, loop or airoot can be ignored.

Note: In the sections below, the sdxy notation will be used (x for the device, y for an existing partition).

If the existing partition scheme does not need to be changed, you may skip to #Format the partitions.

Partition the devices

Partitioning a hard drive divides the available space into sections that can be accessed independently. The required information is stored in a partition table using a format such as MBR or GPT. Existing tables can be printed with parted /dev/sdx print or fdisk -l /dev/sdx.

To partition devices, use a partitioning tool compatible to the chosen type of partition table. Incompatible tools may result in the destruction of that table, along with existing partitions or data. Choices include:

Name MBR GPT Variants
fdisk Yes Yes sfdisk, cfdisk
gdisk No Yes cgdisk, sgdisk
parted Yes Yes GParted

The examples below demonstrate a basic partition scheme for both types of partition tables. They assume that a new, contiguous layout is applied to a single device in /dev/sdx. Necessary changes to device names and partition numbers must be done beforehand.

UEFI/GPT example layout
Mount point Partition Partition type (GUID) Bootable flag Suggested size
/boot /dev/sdx1 EFI System Partition Yes 260–512 MiB
[SWAP] /dev/sdx2 Linux swap No More than 512 MiB
/ /dev/sdx3 Linux No Remainder of the device
MBR/BIOS example layout
Mount point Partition Partition type Bootable flag Suggested size
[SWAP] /dev/sdx1 Linux swap No More than 512 MiB
/ /dev/sdx2 Linux Yes Remainder of the device

Format the partitions

Warning: If dual-booting with an existing installation of Windows on a UEFI/GPT system, avoid reformatting the UEFI partition, as this includes the Windows .efi file required to boot it.

Once the partitions have been created, each must be formatted with an appropriate file system, except for swap partitions. All available partitions on the intended installation device can be listed with the following command:

# lsblk /dev/sdx

With the exceptions noted below, it is recommended to use the ext4 file system:

# mkfs.ext4 /dev/sdxy

If a swap partition was created, it must be set up and activated with:

# mkswap /dev/sdxy
# swapon /dev/sdxy

If a new UEFI system partition has been created on a UEFI/GPT system, it must be formatted with a fat32 file system:

# mkfs.fat -F32 /dev/sdxy

Mount the partitions

Mount the root partition to the /mnt directory of the live system:

# mount /dev/sdxy /mnt

Remaining partitions except swap may be mounted in any order, after creating the respective mount points. For example, when using a /boot partition:

# mkdir -p /mnt/boot
# mount /dev/sdxy /mnt/boot

/mnt/boot is also recommended for mounting the (formatted or already existing) EFI System Partition on a UEFI/GPT system. See EFISTUB and related articles for alternatives.

Installation

Select the mirrors

Packages to be installed must be downloaded from mirror servers, which are defined in /etc/pacman.d/mirrorlist. On the live system, all mirrors are enabled, and sorted by their synchronization status and speed at the time the installation image was created.

The higher a mirror is placed in the list, the more priority it is given when downloading a package. You may want to edit the file accordingly, and move the geographically closest mirrors to the top of the list, although other criteria should be taken into account.

The pacstrap tool used in the next step also installs a copy of the file to the new system, so it is worth getting right.

Install the base packages

Execute the pacstrap script:

# pacstrap /mnt

which defaults to install the base group of packages.

This group represents the recommended minimum of packages for an Arch Linux installation. The group does not include all tools from the live installation, such as btrfs-progs; see packages.both for comparison.

To build packages from the AUR or with the ABS, the base-devel group is also required. Packages can be installed with pacman(8) anytime after the #Change root step later, or by appending their names to the pacstrap command. For example:

# pacstrap -i /mnt base base-devel btrfs-progs

The -i switch ensures prompting before package installation.

With the base group, the first initramfs will be generated and installed to the new system's boot path; double-check output prompts ==> Image creation successful for it.

Configuration

fstab

Generate an fstab file. The -U option indicates UUIDs. Labels can be used instead through the -L option.

# genfstab -U /mnt >> /mnt/etc/fstab

Check the resulting file in /mnt/etc/fstab afterwards, and edit it in case of errors.

Change root

Chroot to the new system:

# arch-chroot /mnt /bin/bash

Locale

The Locale defines which language the system uses, and other regional considerations such as currency denomination, numerology, and character sets.

Uncomment en_US.UTF-8 UTF-8 in /etc/locale.gen, as well as other needed localisations. Save the file, and generate the new locales:

# locale-gen

Create /etc/locale.conf, where en_US.UTF-8 refers to the first column of an uncommented entry in /etc/locale.gen:

/etc/locale.conf
LANG=en_US.UTF-8

If you set the keyboard layout, make the changes persistent in /etc/vconsole.conf. For example, if de-latin1 was set with loadkeys, and lat9w-16 with setfont, assign the KEYMAP and FONT variables accordingly:

/etc/vconsole.conf
KEYMAP=de-latin1
FONT=lat9w-16

Time

Select a time zone:

# tzselect

Create the symbolic link /etc/localtime, where Zone/Subzone is the TZ value from tzselect:

# ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime

It is recommended to adjust the time skew, and set the time standard to UTC:

# hwclock --systohc --utc

If other operating systems are installed on the machine, they must be configured accordingly. See Time for details.

Initramfs

Because mkinitcpio was run on installation of linux with pacstrap, most users do not need to regenerate the intramfs image so this step can be skipped.

For special configurations, set the correct hooks in /etc/mkinitcpio.conf and re-generate the initramfs image:

# mkinitcpio -p linux

Boot loader

See Category:Boot loaders for available choices and configurations. Choices include GRUB (BIOS/UEFI), systemd-boot (UEFI) and syslinux (BIOS).

If you have an Intel CPU, in addition to installing a boot loader, install the intel-ucode package and enable microcode updates.

Network configuration

The procedure is similar to #Connect to the Internet for the live installation environment, except made persistent for subsequent boots.

Hostname

Set the hostname by adding an entry to /etc/hostname, where myhostname is the desired host name:

/etc/hostname
myhostname

It is recommended to append the same host name to /etc/hosts, for example:

/etc/hosts
127.0.0.1	localhost.localdomain	localhost	 myhostname
::1		localhost.localdomain	localhost	 myhostname

Wired

When only requiring a single wired connection, enable the dhcpcd service:

# systemctl enable dhcpcd@interface.service

Where interface is an ethernet device name.

See Network configuration#Configure the IP address for other available methods.

Wireless

Install the iw, wpa_supplicant, and (for wifi-menu) dialog packages:

# pacman -S iw wpa_supplicant dialog

Additional firmware packages may also be required. When using wifi-menu, do so after #Unmount the partitions and reboot.

See Wireless#Wireless management for other available methods.

Root password

Set the root password with:

# passwd

Unmount the partitions and reboot

Exit from the chroot environment by running exit or pressing Ctrl+D.

Partitions will be unmounted automatically by systemd on shutdown. You may however unmount manually as a safety measure:

# umount -R /mnt

If the partition is "busy", you can find the cause with fuser. Reboot the computer.

# reboot

Remove the installation media, or you may boot back into it. You can log into your new installation as root, using the password you specified with passwd.

Post-installation

Your new Arch Linux base system is now a functional GNU/Linux environment ready to be built into whatever you wish or require for your purposes. You are now strongly advised to read the General recommendations article, especially the first two sections. Its other sections provide links to post-installation tutorials like setting up a graphical user interface, sound or a touchpad.

For particular areas of interest, see the List of applications.